<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:template match="/">
<xsl:param name="i" select="0"/>
    <h2>My Sessions List</h2>
		<table class = "usersTable">
			<tr>
			<th>ID</th>
			<th>Course</th>
			<th>Day</th>
			<th>Start</th>
			<th>End</th>
      </tr>
      <xsl:for-each select="Calendar/Session">
      <tr>
        <td><xsl:value-of select="position()"/></td>
        <td><xsl:value-of select="Course" /></td>
        <xsl:call-template name="parseDay">
			<xsl:with-param name="day" select="Day"/>
        </xsl:call-template>
         <xsl:call-template name="parseTimeStart">
			<xsl:with-param name="time" select="Start"/>
        </xsl:call-template>
        <xsl:call-template name="parseTimeEnd">
			<xsl:with-param name="time1" select="End"/>
        </xsl:call-template>
      </tr>
      </xsl:for-each>
    </table>
</xsl:template>

  <xsl:template name="parseDay">
    <xsl:param name="day"/>
        <td>
			 <xsl:if test="$day = 1">
			  <xsl:value-of select="'Sunday'"/>
			 </xsl:if>
			 <xsl:if test="$day = 2">
			  <xsl:value-of select="'Monday'"/>
			 </xsl:if>
			 <xsl:if test="$day = 3">
			  <xsl:value-of select="'Tuesday'"/>
			 </xsl:if>
			 <xsl:if test="$day = 4">
			  <xsl:value-of select="'Wednesday'"/>
			 </xsl:if>
			 <xsl:if test="$day = 5">
			  <xsl:value-of select="'Thursday'"/>
			 </xsl:if>
			 <xsl:if test="$day = 6">
			  <xsl:value-of select="'Friday'"/>
			 </xsl:if>
			 <xsl:if test="$day = 7">
			  <xsl:value-of select="'Saturday'"/>
			 </xsl:if>
        </td>
  </xsl:template>
    <xsl:template name="parseTimeStart">
    <xsl:param name="time"/>
        <td>
          <xsl:value-of select="concat($time, ':00')"/>
        </td>
  </xsl:template>
      <xsl:template name="parseTimeEnd">
    <xsl:param name="time1"/>
        <td>
          <xsl:value-of select="concat($time1, ':00')"/>
        </td>
  </xsl:template>
</xsl:stylesheet>